package com.dubbo.controller;

import com.dubbo.common.check.CheckUtil;
import com.dubbo.common.redis.RedisDao;
import com.dubbo.common.result.ResultInfo;
import com.dubbo.common.security.SecurityUtils;
import com.dubbo.domain.User;
import com.dubbo.domain.info.ResultMessage;
import com.dubbo.service.business.pay.WalletPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 钱包支付
 * @author lihongwu
 * 2019年1月9日 上午10:30:06
 */
@RestController
@RequestMapping("/walletPay")
public class WalletPayController {
	
	@Autowired
	private WalletPayService walletPayService;
	@Autowired
	private RedisDao redisDao;
	
	@PostMapping("/walletPayOrder")
	public Map<String,Object> walletPayOrder(HttpServletRequest request, String orderId) throws Exception{
		User user = (User) CheckUtil.checkOline3(request);
		//校验代理商角色
		SecurityUtils.checkRole(ResultMessage.ROLE_AGENT, redisDao, request.getHeader(ResultInfo.USERTOKEN));
		return walletPayService.walletPayOrder(user,orderId);
	}
}
